#ifndef __PID_H__
#define __PID_H__

typedef struct
{
    float  Ref;   			// Input: Reference input(target value)
    float  Fdb;   			// Input: Feedback input
    float  Err;				// Variable: Error

    float  Kp;				// Parameter: Proportional gain
    float  Ki;			    // Parameter: Integral gain
    float  Kd; 		        // Parameter: Derivative gain

    float  Ap;
    float  Bp;
    float  Cp;
    float  Ai;
    float  Ci;
    float  Ad;
    float  Bd;
    float  Cd;
    float  Kl;              //积分分离控制算法前面乘的系数
    float  ErrRef;          //error的阀值，当超过这个值后不使用ki(积分分离控制算法)


    float  Up;				// Variable: Proportional output
    float  Ui;				// Variable: Integral output
    float  Ud;				// Variable: Derivative output
    float  OutPreSat; 		// Variable: Pre-saturated output
    float  OutMax;		    // Parameter: Maximum output
    float  UiOutMax;	    	// Parameter: Maximum Ui output
    float  Out;   			// Output: PID output
    float  SatErr;			// Variable: Saturated difference
    float  Kc;		     	// Parameter: Integral correction gain
    float  Up1;		   	    // History: Previous proportional output
    void  (*calc)();	  	// Pointer to calculation function
    void  (*clear)();
    void  (*calc2)();
} PID;
/*------------------------------------------------------------------------------
Prototypes for the functions in PID.C
------------------------------------------------------------------------------*/
void PidCalc(PID *v);
void PidClear(PID *v);
void PidCalc2(PID *v);

#endif
